Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

anymatch

Package Overview
Dependencies
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anymatch

Matches strings against configurable strings, globs, regular expressions, and/or functions

  • 3.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50M
decreased by-11.41%
Maintainers
5
Weekly downloads
 
Created

What is anymatch?

The anymatch npm package is a utility that allows you to match strings against a variety of patterns including strings, regexes, and functions. It is commonly used to test whether a given string matches any of a set of criteria, which is useful for tasks like filtering file paths or determining if an event should trigger a particular action.

What are anymatch's main functionalities?

String pattern matching

Match a string against a single glob pattern.

"foo.js".match(anymatch('*.js'))

Array of patterns matching

Match a string against an array of glob patterns.

anymatch(['*.js', '*.css'], 'foo.js')

Function as a custom matcher

Use a function as a custom matcher in the array of patterns.

anymatch([/\.js$/, (string) => string.includes('foo')], 'foo.js')

Negated patterns

Use negated patterns to exclude matches.

anymatch(['*.js', '!foo.js'], 'foo.js')

Partial application

Create a partially applied matcher function for reuse.

const isJsFile = anymatch('*.js');
isJsFile('foo.js');

Other packages similar to anymatch

Keywords

FAQs

Package last updated on 21 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc